﻿<UserControl x:Class="BillsManager.Views.DataTemplates.SupplierDataTemplate"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:Models="clr-namespace:BillsManager.Models;assembly=BillsManager.Models"
             xmlns:ViewModels="clr-namespace:BillsManager.ViewModels;assembly=BillsManager.ViewModels"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             d:DataContext="{d:DesignInstance Type=ViewModels:SupplierViewModel,
                                              IsDesignTimeCreatable=True}"
             d:DesignWidth="200"
             mc:Ignorable="d">

    <UserControl.Resources>

        <ResourceDictionary>

            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/BillsManager.Views;component/Dictionaries/Styles.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <Style x:Key="ObligationStatusRectangleStyle" TargetType="{x:Type Rectangle}">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding ObligationState}" Value="{x:Static Models:Obligation.Debtor}">
                        <DataTrigger.Setters>
                            <Setter Property="Fill" Value="{StaticResource Obligation.Debtor.Brush}" />
                        </DataTrigger.Setters>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ObligationState}" Value="{x:Static Models:Obligation.Unbound}">
                        <DataTrigger.Setters>
                            <Setter Property="Fill" Value="{StaticResource Obligation.Unbound.Brush}" />
                        </DataTrigger.Setters>
                    </DataTrigger>
                    <DataTrigger Binding="{Binding ObligationState}" Value="{x:Static Models:Obligation.Creditor}">
                        <DataTrigger.Setters>
                            <Setter Property="Fill" Value="{StaticResource Obligation.Creditor.Brush}" />
                        </DataTrigger.Setters>
                    </DataTrigger>
                </Style.Triggers>
            </Style>

        </ResourceDictionary>

    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="12" />
            <!--  obligation color  -->
            <ColumnDefinition Width="{StaticResource View.MarginSize}" />
            <ColumnDefinition Width="Auto" SharedSizeGroup="col2" />
            <!--  name  -->
            <ColumnDefinition Width="24" />
            <ColumnDefinition Width="Auto" SharedSizeGroup="col4" />
            <!--  total  -->
            <ColumnDefinition />
            <ColumnDefinition Width="{StaticResource View.MarginSize}" />
        </Grid.ColumnDefinitions>

        <Rectangle Grid.RowSpan="5" Style="{StaticResource ObligationStatusRectangleStyle}" />

        <TextBlock Grid.Row="1"
                   Grid.Column="2"
                   HorizontalAlignment="Left"
                   Text="{Binding Name}" />

        <TextBlock Grid.Row="1"
                   Grid.Column="4"
                   HorizontalAlignment="Right"
                   Language="it-IT"
                   Text="{Binding ObligationAmount,
                                  StringFormat=\{0:c\}}" />

        <TextBlock Grid.Row="3"
                   Grid.Column="2"
                   HorizontalAlignment="Left"
                   Text="{Binding Phone}" />

        <TextBlock Grid.Row="3"
                   Grid.Column="4"
                   Grid.ColumnSpan="2"
                   HorizontalAlignment="Left" />
    </Grid>
</UserControl>